package com.example.order.web;

import com.example.order.common.configure.PatternProperties;
import com.example.order.pojo.Order;
import com.example.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 订单服务
 */
@RestController
@RequestMapping("/order")
@Slf4j
// @RefreshScope
public class OrderController {
	@Autowired
	private OrderService orderService;


	// @Value("${logging.pattern1.dateformat}")
	// private String dateformat;

	// @GetMapping("now")
	// public String now(){
	// 	return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateformat));
	// }

	@Autowired
	private PatternProperties patternProperties;
	@GetMapping("now")
	public String now(){
		return LocalDateTime.now().format(DateTimeFormatter.ofPattern(patternProperties.getDateformat()));
	}
	@GetMapping("prop")
	public PatternProperties properties(){
		return patternProperties;
	}

	/**
	 * 获取信息
	 * @param id 标识
	 * @return
	 */
	@RequestMapping("/query/{id}")
	public Order queryById(@PathVariable("id") String id){
		return orderService.queryById(id);
	}



	// @GetMapping("/query")
	// public String query

}
